package net.lqy.aipan.config;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import net.lqy.aipan.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @title: InterceptorConfig
 * @Author lqy
 * @Date: 2025-06-03 21:51
 * @Version 1.0
 */
@Configuration
@Slf4j
public class InterceptorConfig implements WebMvcConfigurer {
    @Resource
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                // 添加需要拦截的路径
                .addPathPatterns("/api/*/account/**", "/api/*/file/**", "/api/*/share/**","/api/*/account_file/**")
                // 排除不需要拦截的路径
                .excludePathPatterns(
                        "/api/*/account/register",
                        "/api/*/account/login",
                        "/api/*/account/upload_avatar",
                        "/api/*/share/check_share_code",
                        "/api/*/share/visit",
                        "/api/*/share/detail_no_code",
                        "/api/*/share/detail_with_code"
                );
    }
}
